from flask import Flask, request
from database import *

app = Flask(__name__)

create_database_if_not_exists()


@app.route('/')
def get_videos():
    videos = get_all_videos()
    # return json
    return {'videos': videos}


@app.post('/project')
# def create_project(request):
#     project = request.json
#     if not project:
#         return {'status': 'failed'}
#     if project.get('name') is None:
#         return {'status': 'failed'}
#     create_project(project)
#     return {'status': 'success'}
def create_project():
    project = request.json
    if not project:
        return {'status': 'failed'}
    if project.get('name') is None:
        return {'status': 'failed'}
    create_project(project)
    return {'status': 'success'}


if __name__ == '__main__':
    app.run()
